﻿
let curve: Curve;
window.onload = () => {
    
    curve = new Curve(document.body);

    valueDiv = document.createElement("div");
    valueDiv.style.height = window.outerHeight + "px";
    valueDiv.style.width = window.outerWidth + "px";
    valueDiv.style.position = "absolute";
    valueDiv.style.top = "0px";
    valueDiv.style.left = "0px";
    document.body.appendChild(valueDiv);
    let div = document.createElement("div");
    div.style.backgroundColor = "rgb(0,0,0)";
    div.style.height = "100px";
    div.style.width = "100px";
    div.style.left = "0px";
    div.style.top = "0px";
    valueDiv.appendChild(div);
    let myTest = new MyTest(div);
    new DragDiv(div).refreshPosition = () => {
        myTest.refreshPosition();
    };

    let div1 = document.createElement("div");
    div1.style.backgroundColor = "rgb(0,0,0)";
    div1.style.height = "100px";
    div1.style.width = "100px";
    div1.style.left = "0px";
    div1.style.top = "0px";
    valueDiv.appendChild(div1);
    let myTest1 = new MyTest(div1);
    let myText3 = new MyTest1(div1);
    new DragDiv(div1).refreshPosition = () => {
        myTest1.refreshPosition();
        myText3.refreshPosition();
    };

    let div2 = document.createElement("div");
    div2.style.backgroundColor = "rgb(0,0,0)";
    div2.style.height = "100px";
    div2.style.width = "100px";
    div2.style.left = "0px";
    div2.style.top = "0px";
    valueDiv.appendChild(div2);
    let myTest2 = new MyTest1(div2);
    new DragDiv(div2).refreshPosition = () => {
        myTest2.refreshPosition();
    };

    
}

class MyTest1 extends MyNode {
    setMyDiv(div: HTMLDivElement) {
        div.style.top = "30px";
        div.style.height = "20px";
        div.style.width = "20px";
        div.style.backgroundColor = "rgb(255,0,0)";
    }
    sethideDiv(div: HTMLDivElement) {
        div.style.height = "20px";
        div.style.width = "20px";
        div.style.backgroundColor = "rgb(0,255,0)";
    }
    NewCuve() {
        this.curve.Sd = Direction.Left;
        this.curve.Sl = 100;
    }
    connectCuve() {
        this.curve.Ed = Direction.Left;
        this.curve.El = 100;
    }
}


class MyTest extends MyNode {
    setMyDiv(div: HTMLDivElement) {
        div.style.height = "20px";
        div.style.width = "20px";
        div.style.backgroundColor = "rgb(255,0,0)";
    }
    sethideDiv(div: HTMLDivElement) {
        div.style.height = "20px";
        div.style.width = "20px";
        div.style.backgroundColor = "rgb(0,255,0)";
    }
    NewCuve() {
        this.curve.Sd = Direction.Top;
        this.curve.Sl = 100;
    }
    connectCuve() {
        this.curve.Ed = Direction.Left;
        this.curve.El = 100;
    }
}

